<template>
  <div>
    <Row>
      <DatePicker type="date" @on-change="getStartTime" placeholder="Select date" style="width: 200px"></DatePicker>
      <span @click="getDataList" style="margin: 0 10px;"><Button type="primary" icon="search">搜索</Button></span>
    </Row>
    <Table :columns="columns" :data="dataList"></Table>
  </div>
</template>
<script>
export default {
  data () {
    return {
      logDate: '',
      columns: [
        {
          title: '访问时间',
          key: 'createDateTime'
        },
        {
          title: '文章标题',
          key: 'title'
        },
        {
          title: '访问者IP地址',
          key: 'ip'
        }
      ],
      dataList: []
    }
  },
  created () {
    this.getDataList();
  },
  methods: {
    getStartTime (date) {
      this.logDate = date;
    },
    getDataList () {
      this.$http({
        url: this.$http.adornUrl('/log/sheet/list'),
        method: 'get',
        params: this.$http.adornParams({
          'date': this.logDate
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataList = data.list;
        } else {
          this.$Message.warning('获取记录异常');
        }
      })
    }
  }
}
</script>
